import 'package:winkai/generated/json/base/json_convert_content.dart';
import 'package:winkai/entity/role_info.dart';
import 'package:winkai/db/database.dart';

import 'package:winkai/ext/ext.dart';


RoleInfo $RoleInfoFromJson(Map<String, dynamic> json) {
  final RoleInfo roleInfo = RoleInfo();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    roleInfo.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    roleInfo.name = name;
  }
  final int? age = jsonConvert.convert<int>(json['age']);
  if (age != null) {
    roleInfo.age = age;
  }
  final String? aboutMe = jsonConvert.convert<String>(json['about_me']);
  if (aboutMe != null) {
    roleInfo.aboutMe = aboutMe;
  }
  final String? renderStyle = jsonConvert.convert<String>(json['render_style']);
  if (renderStyle != null) {
    roleInfo.renderStyle = renderStyle;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    roleInfo.avatar = avatar;
  }
  final List<String>? greetings = (json['greetings'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (greetings != null) {
    roleInfo.greetings = greetings;
  }
  return roleInfo;
}

Map<String, dynamic> $RoleInfoToJson(RoleInfo entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['age'] = entity.age;
  data['about_me'] = entity.aboutMe;
  data['render_style'] = entity.renderStyle;
  data['avatar'] = entity.avatar;
  data['greetings'] = entity.greetings;
  return data;
}

extension RoleInfoExtension on RoleInfo {
  RoleInfo copyWith({
    String? id,
    String? name,
    int? age,
    String? aboutMe,
    String? renderStyle,
    String? avatar,
    List<String>? greetings,
  }) {
    return RoleInfo()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..age = age ?? this.age
      ..aboutMe = aboutMe ?? this.aboutMe
      ..renderStyle = renderStyle ?? this.renderStyle
      ..avatar = avatar ?? this.avatar
      ..greetings = greetings ?? this.greetings;
  }
}